package com.redxun.config;

import com.redxun.filter.ApiTokenFilter;
import com.redxun.filter.HttpTokenRequestFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 跨域配置
 * @author aj
 *
 * @date 2018/8/9 15:59
 */
@Configuration
public class WebConfigration {
    
    private static final String ALL = "*";
    

    @Bean
    public FilterRegistrationBean registerApiTokenFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new ApiTokenFilter());
        registration.addUrlPatterns(ALL);
        registration.setName("apiTokenFilter");
        registration.setOrder(1002);
        return registration;
    }
    
    @Bean
    public FilterRegistrationBean registerHttpTokenFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new HttpTokenRequestFilter());
        registration.addUrlPatterns(ALL);
        registration.setName("httpTokenRequestFilter");
        registration.setOrder(1003);
        return registration;
    }

}

